import re
from PyQt5.QtCore import QThread, pyqtSignal, pyqtSlot


class ParseThread(QThread):
    parsed = pyqtSignal(dict)

    def __init__(self, message):
        super().__init__()
        self.message = message

    def run(self):
        pattern = r"-(\w+)\s+([\w:]+)"
        lines = self.message.strip().split("\n")
        fields = {}
        for line in lines:
            match = re.search(pattern, line)
            if match:
                fields[match.group(1)] = match.group(2)
        self.parsed.emit(fields)


if __name__ == "__main__":
    from PyQt5.QtWidgets import QApplication, QLabel

    app = QApplication([])
    label = QLabel("Parsing...")
    label.show()

    def handle_parsed(fields):
        label.setText(str(fields))

    message = """ZCZC
    -TITLE IFPL
    -FILTIM 010909
    -IFPLID 201332005
    -SOURCE AIRNET:ZUCK
    -ARCID CSN6435
    -ADEP ZBAA
    -ADES ZUUU
    -EOBD 20130301
    -EOBT 0850
    -SSRCODE A1270
    NNNN"""

    thread = ParseThread(message)
    thread.parsed.connect(handle_parsed)
    thread.start()

    app.exec_()
